<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>解构变量的简写形式与变量解构</title>
</head>
<body>
    <script>
        // 取所有属性
        let user = {
            name:"xiasnn",
            age:18
        };
        let {name,age} = user;
        console.log(name,age);


        // 只取一个属性
        let book = {
            name:"js",
            price:99
        };
        let {price} = book;
        console.log(price);


        // 变量转化为对象
        let lesson = "css";
        let click = 22;
        // let opt = {lesson:lesson,click:click};
        // 简写
        let opt = {lesson,click};
        console.log(opt);
    </script>
</body>
</html>